import java.io.*;
import java.sql.*;
import javax.servlet.http.*;

public class StudentSearchServlet extends HttpServlet
{
  String website="";
	String email="";
	String tel_no="";
	String ssc=null;
	String inter="";
String graduation="";
String pg="";
String pg_year="";
String technical_skills="";
    @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
  {

     try
       {
  String  company_name=request.getParameter("company");

         response.setContentType("text/html");
         PrintWriter out=response.getWriter();


        Class.forName("oracle.jdbc.driver.OracleDriver");

         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","pac","mca"); 

         Statement stmt=con.createStatement();
         
             ResultSet rs = stmt.executeQuery("SELECT *from company_register WHERE company_name='"+company_name+"'");

             
         if(rs.next())

         {
             
                company_name=rs.getString(1);
	  website=rs.getString(2);
	  email=rs.getString(3);
	   tel_no=rs.getString(4);
        }
            
          ResultSet rs4=stmt.executeQuery("SELECT *FROM company_requirement  JOIN COMPANY_REGISTER on  company_requirement.COMPANY_UNAME=COMPANY_REGISTER.COMPANY_UNAME ");

        if(rs4.next())
        {
      ssc= rs4.getString(1);System.out.println(rs4.getString(1));
        inter =  rs4.getString(2);         
        graduation =  rs4.getString(3);
         pg =rs4.getString(4);         
            pg_year =rs4.getString(5); 
    technical_skills=rs4.getString(6);                             
        }


        out.println("<html>");
      out.println("<body bgcolor='CC9900'>"); 
       out.println("<br><h1> <font color=\"white\"> "+company_name+" </font> </h1> ");
      out.println("<center>");
	
        

     out.println("<table cellspacing='3'>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Id  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+company_name+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">email  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+email+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> website  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+website+" </font> </b>");
        out.println("</tr>");   
     out.println("<font color='white'>The candidtae who wants to apply should have tha  follwing requirements</font>");
        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> SSC Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+ssc+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Intermediate Marks Percentage </font>  </b>");
              out.println("<td> <b> <font color=\"white\"> :"+inter+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\">Degree Marks Percentage  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+graduation+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> PG Marks Percentage </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg+" </font> </b>");
        out.println("</tr>");

        out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> Year of Passing  </font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+pg_year+" </font> </b>");
        out.println("</tr>");
   out.println("<tr>");
              out.println(" <td> <b> <font color=\"black\"> technical skills</font> </b>");
              out.println("<td> <b> <font color=\"white\"> :"+technical_skills+" </font> </b>");
        out.println("</tr>");
out.println("<br><br><br>");
     out.println(" </table> ");
     
     out.println("<form action='registration.jsp?"+company_name+"' method='post' >"
             + "<input type='hidden'  name='company_name' value='"+company_name+"' >");
     out.println("<input type='submit' value='apply'></form></center>");
     
     out.println("</body>");

     out.println("</html>");   
    
 }
         
     
 
    catch(Exception e)
       {
      
        // response.sendError(505,e.getMessage());
         e.printStackTrace();       
}   

  }

}  

 